package com.yuexunit.operationman.nbsy.module.InterventionalOperation.ui;

import android.view.View;
import android.widget.TextView;


import com.yuexunit.operationman.nbsy.R;
import com.yuexunit.operationman.nbsy.base.BaseKJActivity;
import com.yuexunit.operationman.nbsy.base.ExitApplication;
import com.yuexunit.operationman.nbsy.config.AppConfig;
import com.yuexunit.operationman.nbsy.module.InterventionalOperation.Bean.InterNursingBean;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by chenss on 2017/7/24 0024.
 */

public class Act_InterventionalOperation_Preview_Old extends BaseKJActivity {

    @Bind(R.id.tv_patient_name)
    TextView tvPatientName;
    @Bind(R.id.tv_patient_sex)
    TextView tvPatientSex;
    @Bind(R.id.tv_patient_visitno)
    TextView tvPatientVisitno;
    @Bind(R.id.tv_patient_disease)
    TextView tvPatientDisease;
    @Bind(R.id.anesthesia_type)
    TextView anesthesiaType;
    @Bind(R.id.narcotic)
    TextView narcotic;
    @Bind(R.id.dosage)
    TextView dosage;
    @Bind(R.id.anesthesia)
    TextView anesthesia;
    @Bind(R.id.anesthesia_start)
    TextView anesthesiaStart;
    @Bind(R.id.anesthesia_end)
    TextView anesthesiaEnd;
    @Bind(R.id.opration_start)
    TextView oprationStart;
    @Bind(R.id.opration_end)
    TextView oprationEnd;
    @Bind(R.id.transfuse_drug)
    TextView transfuseDrug;
    @Bind(R.id.doctor_signature)
    TextView doctorSignature;
    @Bind(R.id.rate_0)
    TextView rate0;
    @Bind(R.id.bp_0)
    TextView bp0;
    @Bind(R.id.oxygen_0)
    TextView oxygen0;
    @Bind(R.id.rate_1)
    TextView rate1;
    @Bind(R.id.bp_1)
    TextView bp1;
    @Bind(R.id.oxygen_1)
    TextView oxygen1;
    @Bind(R.id.rate_2)
    TextView rate2;
    @Bind(R.id.bp_2)
    TextView bp2;
    @Bind(R.id.oxygen_2)
    TextView oxygen2;
    @Bind(R.id.rate_3)
    TextView rate3;
    @Bind(R.id.bp_3)
    TextView bp3;
    @Bind(R.id.oxygen_3)
    TextView oxygen3;
    @Bind(R.id.rate_4)
    TextView rate4;
    @Bind(R.id.bp_4)
    TextView bp4;
    @Bind(R.id.oxygen_4)
    TextView oxygen4;
    @Bind(R.id.rate_5)
    TextView rate5;
    @Bind(R.id.bp_5)
    TextView bp5;
    @Bind(R.id.oxygen_5)
    TextView oxygen5;
    @Bind(R.id.rate_6)
    TextView rate6;
    @Bind(R.id.bp_6)
    TextView bp6;
    @Bind(R.id.oxygen_6)
    TextView oxygen6;
    @Bind(R.id.rate_7)
    TextView rate7;
    @Bind(R.id.bp_7)
    TextView bp7;
    @Bind(R.id.oxygen_7)
    TextView oxygen7;
    @Bind(R.id.rate_8)
    TextView rate8;
    @Bind(R.id.bp_8)
    TextView bp8;
    @Bind(R.id.oxygen_8)
    TextView oxygen8;
    @Bind(R.id.rate_9)
    TextView rate9;
    @Bind(R.id.bp_9)
    TextView bp9;
    @Bind(R.id.oxygen_9)
    TextView oxygen9;
    @Bind(R.id.rate_10)
    TextView rate10;
    @Bind(R.id.bp_10)
    TextView bp10;
    @Bind(R.id.oxygen_10)
    TextView oxygen10;
    @Bind(R.id.rate_11)
    TextView rate11;
    @Bind(R.id.bp_11)
    TextView bp11;
    @Bind(R.id.oxygen_11)
    TextView oxygen11;
    @Bind(R.id.rate_12)
    TextView rate12;
    @Bind(R.id.bp_12)
    TextView bp12;
    @Bind(R.id.oxygen_12)
    TextView oxygen12;
    @Bind(R.id.rate_end)
    TextView rateEnd;
    @Bind(R.id.bp_end)
    TextView bpEnd;
    @Bind(R.id.oxygen_end)
    TextView oxygenEnd;

    @Override
    public void setRootView() {
        setContentView(R.layout.act_interventionaloperation_preview_old);
        ButterKnife.bind(this);
        ExitApplication.getInstance().addActivity(this);
    }

    @Override
    public void initData() {
        super.initData();
        setTitle();
        setContent();
    }

    private void setTitle() {
        tvPatientName.setText(AppConfig.INTERNURSEBEAN.getObject().getInterNursing().getPatientName());
        if (AppConfig.INTERNURSEBEAN.getObject().getInterNursing().getPatientSex().equals("1")) {
            tvPatientSex.setText("男");
        } else if (AppConfig.INTERNURSEBEAN.getObject().getInterNursing().getPatientSex().equals("2")) {
            tvPatientSex.setText("女");
        } else {
            tvPatientSex.setText("不详");
        }
        tvPatientVisitno.setText("住院号" + AppConfig.INTERNURSEBEAN.getObject().getInterNursing().getInHospitalNo());
        tvPatientDisease.setText(AppConfig.INTERNURSEBEAN.getObject().getInterNursing().getClinicalDiagnosis());
    }

    private void setContent() {
        if(AppConfig.INTERNURSEBEAN.getObject().getInterNursing().getAnaesthesiaType() != null) {
            if (AppConfig.INTERNURSEBEAN.getObject().getInterNursing().getAnaesthesiaType().equals("1")) {
                anesthesiaType.setText("全麻");
            } else if (AppConfig.INTERNURSEBEAN.getObject().getInterNursing().getAnaesthesiaType().equals("2")) {
                anesthesiaType.setText("局麻");
            }
        }
        if(AppConfig.INTERNURSEBEAN.getObject().getInterNursing().getAnaesthesiaMeasure() != null) {
            if (AppConfig.INTERNURSEBEAN.getObject().getInterNursing().getAnaesthesiaMeasure().length() > 0) {
                narcotic.setText(AppConfig.INTERNURSEBEAN.getObject().getInterNursing().getAnaesthesiaMeasure().split(";", -1)[0]);
                dosage.setText(AppConfig.INTERNURSEBEAN.getObject().getInterNursing().getAnaesthesiaMeasure().split(";", -1)[1]);
            }
        }
        anesthesia.setText(AppConfig.INTERNURSEBEAN.getObject().getInterNursing().getAnestheSign());
        anesthesiaStart.setText(AppConfig.INTERNURSEBEAN.getObject().getInterNursing().getAnesthesiaStartTimeStr());
        anesthesiaEnd.setText(AppConfig.INTERNURSEBEAN.getObject().getInterNursing().getAnesthesiaEndTimeStr());
        oprationStart.setText(AppConfig.INTERNURSEBEAN.getObject().getInterNursing().getOperationStartTimeStr());
        oprationEnd.setText(AppConfig.INTERNURSEBEAN.getObject().getInterNursing().getOperationEndTimeStr());
        transfuseDrug.setText(AppConfig.INTERNURSEBEAN.getObject().getInterNursing().getOperationDoctorSign());
        doctorSignature.setText(AppConfig.INTERNURSEBEAN.getObject().getInterNursing().getOperationMedicine());

        for (InterNursingBean.ObjectEntity.InterNursingItemListEntity p : AppConfig.INTERNURSEBEAN.getObject().getInterNursingItemList()) {
            switch (p.getItemCode()) {
                case "P":
                    if (p.getItemValue().length() > 0) {
                        String[] skin = p.getItemValue().split(";", -1);
                        rate0.setText(skin[0]);
                        rate1.setText(skin[1]);
                        rate2.setText(skin[2]);
                        rate3.setText(skin[3]);
                        rate4.setText(skin[4]);
                        rate5.setText(skin[5]);
                        rate6.setText(skin[6]);
                        rate7.setText(skin[7]);
                        rate8.setText(skin[8]);
                        rate9.setText(skin[9]);
                        rate10.setText(skin[10]);
                        rate11.setText(skin[11]);
                        rate12.setText(skin[12]);
                        rateEnd.setText(skin[13]);
                    }
                    break;
                case "BP":
                    if (p.getItemValue().length() > 0) {
                        String[] skin = p.getItemValue().split(";", -1);
                        bp0.setText(skin[0]);
                        bp1.setText(skin[1]);
                        bp2.setText(skin[2]);
                        bp3.setText(skin[3]);
                        bp4.setText(skin[4]);
                        bp5.setText(skin[5]);
                        bp6.setText(skin[6]);
                        bp7.setText(skin[7]);
                        bp8.setText(skin[8]);
                        bp9.setText(skin[9]);
                        bp10.setText(skin[10]);
                        bp11.setText(skin[11]);
                        bp12.setText(skin[12]);
                        bpEnd.setText(skin[13]);
                    }
                    break;
                case "OS":
                    if (p.getItemValue().length() > 0) {
                        String[] skin = p.getItemValue().split(";", -1);
                        oxygen0.setText(skin[0]);
                        oxygen1.setText(skin[1]);
                        oxygen2.setText(skin[2]);
                        oxygen3.setText(skin[3]);
                        oxygen4.setText(skin[4]);
                        oxygen5.setText(skin[5]);
                        oxygen6.setText(skin[6]);
                        oxygen7.setText(skin[7]);
                        oxygen8.setText(skin[8]);
                        oxygen9.setText(skin[9]);
                        oxygen10.setText(skin[10]);
                        oxygen11.setText(skin[11]);
                        oxygen12.setText(skin[12]);
                        oxygenEnd.setText(skin[13]);
                    }
                    break;
            }
        }
    }

    @OnClick({R.id.titlebar_docadvice_img_back, R.id.tv_submit})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.titlebar_docadvice_img_back:
                finish();
                break;
            case R.id.tv_submit:
                finish();
                break;
        }
    }
}
